var $ = {
    ajax: function ({
      url,
      type = 'get',
      data = {},
      async = true,
      success,
      error,
      complete=function(res){},
      dataType = 'json',
    }) {
      var xhr = new XMLHttpRequest()
      xhr.open(type, url, async)
      xhr.onreadystatechange = function () {
        if (xhr.readyState === 4) {
          if (xhr.status === 200) {
            if(dataType=='json'){
                success(JSON.parse(xhr.responseText))  
            }else if(dataType=='text'){
                success(xhr.responseText)
            }else {
                success(xhr.responseXML)
            }
          } else {
            error(xhr.status)
          }
          complete(xhr)
        }
      }
      if(type.toLowerCase()=='post'){
        xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded')
        xhr.send(data)
      }else{
        xhr.send()
      }
    },
    get:function({}){

    }
  }